package flst.ipiweb.service;

import java.util.ArrayList;
import java.util.List;

import flst.ipiweb.common.User;
import flst.ipiweb.dao.DAOFactory;
import flst.ipiweb.exceptions.IPIWebException;

public class ServiceAdmin {

	public User getAdminByLogin(String login) {

		try {
			return DAOFactory.getAdminDAO().getAdminByLogin(login);
		} catch (IPIWebException e) {
			return null;
		}

	}

	public List<User> listerAdmins() {

		try {
			List<User> list = DAOFactory.getAdminDAO().listerAdmins();
			return list;
		} catch (IPIWebException e) {
			return new ArrayList<User>();
		}

	}

	public User getAdminById(int idAdmin) {

		try {
			return DAOFactory.getAdminDAO().getAdminById(idAdmin);
		} catch (IPIWebException e) {
			return new User();
		}
	}

	public void deleteAdmin(User admin) {

		try {
			DAOFactory.getAdminDAO().deleteAdmin(admin);
		} catch (IPIWebException e) {

		}
	}

	public boolean createAdmin(User admin) {

		try {
			return DAOFactory.getAdminDAO().createAdministrateur(admin);
		} catch (IPIWebException e) {
			return false;
		}

	}

	public void majAdmin(User admin) {

		try {
			DAOFactory.getAdminDAO().majAdmin(admin);
		} catch (IPIWebException e) {

		}
	}

	public int countAdmmin() {

		try {
			return DAOFactory.getAdminDAO().countAdmmin();
		} catch (IPIWebException e) {
			return 0;
		}
	}
	
	public int countAdminByLogin(String login) {

		try {
			return DAOFactory.getAdminDAO().countAdminByLogin(login);
		} catch (IPIWebException e) {
			return 0;
		}
	}
	

}
